/*
 * Copyright (c) 2008-2016 Haulmont.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

@mixin halo-cuba-tokenlist($primary-stylename: c-tokenlist) {
  .#{$primary-stylename} .c-tokenlist-label.v-widget {
    clear: both;
    margin: 0 round($v-layout-margin-right/2) 0 0;
    height: $v-unit-size;
    cursor: pointer;
    display: table;
    padding-left: round($v-layout-margin-left/2);
    width: 100%;
  }

  .#{$primary-stylename} .c-tokenlist-label-close {
    height: $v-unit-size;
    width: $v-unit-size;
    cursor: pointer;
    display: inline-block;
    text-align: center;
    font-size: $v-font-size;
    line-height: $v-unit-size;

    &:after {
      font-family: FontAwesome;
      content: "\f00d";
    }
  }

  .#{$primary-stylename}.v-disabled .#{$primary-stylename}-label-content {
    @include opacity($v-disabled-opacity);
  }

  .#{$primary-stylename}.v-readonly .#{$primary-stylename}-label-close {
    display: none;
  }

  .#{$primary-stylename} .#{$primary-stylename}-label-content {
    white-space: nowrap;
    outline: none;
    font-size: 0;
    padding-right: $v-unit-size;
    overflow: hidden;
  }

  .#{$primary-stylename} .c-tokenlist-label-content .content {
    white-space: nowrap;
    cursor: default;
    overflow: hidden;
    display: inline-block;
    line-height: $v-unit-size;
    font-size: $v-font-size;
    vertical-align: top;
    width: 100%;
  }

  .#{$primary-stylename} .c-tokenlist-label.noedit {
    background-image: none;
    padding-right: $v-layout-margin-right;
  }

  .#{$primary-stylename} .c-tokenlist-label-content.noedit .content {
    margin-right: 0;
  }

  .#{$primary-stylename} .c-tokenlist-label.open .content {
    cursor: pointer;
  }

  .#{$primary-stylename}.inline {
    .c-tokenlist-label.v-widget {
      clear: none;
      margin-right: round($v-layout-margin-right/2);
      float: left;
      width: auto;
      display: inline-block;
    }

    .c-tokenlist-label.v-widget {
      display: inline-block;
    }

    .c-tokenlist-label-content {
      padding-right: 0;
    }

    .c-tokenlist-label-content .content {
      width: auto;
    }
  }

  .#{$primary-stylename} {
    &.v-has-width .v-slot-c-tokenlist-scrollbox {
      max-width: none;
    }

    &.v-has-height .v-slot-c-tokenlist-scrollbox {
      max-height: none;
    }
  }

  .v-slot-c-tokenlist-scrollbox {
    max-width: 400px;
    max-height: 250px;
    overflow: auto;
  }
}